function Stygian_create_prompt()
  local WindowWidth,WindowHeight = getMainWindowSize()
  local fontx,fonty = calcFontSize(Stygian.prompt_fontsize)
  createMiniConsole("Stygian.prompt", 0,0,0,0)
  setBackgroundColor("Stygian.prompt", 0, 0, 0, 255)
  setMiniConsoleFontSize("Stygian.prompt", Stygian.prompt_fontsize)
  setBorderBottom(fonty + 20)  
  resizeWindow("Stygian.prompt", WindowWidth, fonty+2)
  moveWindow("Stygian.prompt", 0, WindowHeight-20 - fonty+2)
  
end


function Stygian_resize_prompt()
  local WindowWidth,WindowHeight = getMainWindowSize()
  local fontx,fonty = calcFontSize(Stygian.prompt_fontsize)
  setBorderBottom(fonty + 20)
  setMiniConsoleFontSize("Stygian.prompt", Stygian.prompt_fontsize)
  resizeWindow("Stygian.prompt", WindowWidth, fonty+2)
  moveWindow("Stygian.prompt", 0, WindowHeight-20 - fonty+2)
  setBackgroundColor("Stygian.prompt", 0, 0, 0, 255)
  
end

function Stygian_update_prompt()
  local promptstring = ""

  if Stygian.balances.balance == 1 then
    Stygian_balance_prompt = "<deep_pink>X"
  else
    Stygian_balance_prompt = "<dim_gray>X"
  end
  if Stygian.balances.equilibrium == 1 then
    Stygian_equilibrium_prompt = "<deep_pink>E"
  else
    Stygian_equilibrium_prompt = "<dim_gray>E"
  end
  if Stygian.balances.leftArm == 1 then
    Stygian.balances.leftArm_prompt = "<deep_pink>l"
  else
    Stygian.balances.leftArm_prompt = "<dim_gray>l"
  end
  if Stygian.balances.rightArm == 1 then
    Stygian.balances.rightArm_prompt = "<deep_pink>r"
  else
    Stygian.balances.rightArm_prompt = "<dim_gray>r"
  end
  if Stygian.defs.kafe == 1 then
    Stygian.defs.kafe_prompt = "<deep_pink>k"
  else
    Stygian.defs.kafe_prompt = "<dim_gray>k"
  end
  if Stygian.prone == 1 then
    Stygian.prone_prompt = "<deep_pink>p"
  else
    Stygian.prone_prompt = "<dim_gray>p"
  end
  if Stygian.blind == 1 then
    Stygian.blind_prompt = "<deep_pink>b"
  else
    Stygian.blind_prompt = "<dim_gray>b"
  end
  if Stygian.deaf == 1 then
    Stygian.deaf_prompt = "<deep_pink>d"
  else
    Stygian.deaf_prompt = "<dim_gray>d"
  end

  if Stygian.config.psi == 1 then
    if Stygian.balances.sub == 1 then
      Stygian.balances.sub_prompt = "<deep_pink>su"
    else
      Stygian.balances.sub_prompt = "<dim_gray>su"
    end
    if Stygian.balances.super == 1 then
      Stygian.balances.super_prompt = "<deep_pink>SU"
    else
      Stygian.balances.super_prompt = "<dim_gray>SU"
    end
    if Stygian.balances.id == 1 then
      Stygian.balances.id_prompt = "<deep_pink>id"
    else
      Stygian.balances.id_prompt = "<dim_gray>id"
    end
  end
  
	

  if Stygian.config.psi == 1 and Stygian.config.armbal == 1 then
    promptstring = Stygian_equilibrium_prompt .. Stygian.balances.leftArm_prompt .. Stygian.balances.rightArm_prompt .. Stygian_balance_prompt .. "<purple>|" .. Stygian.defs.kafe_prompt .. Stygian.blind_prompt .. Stygian.deaf_prompt .. Stygian.prone_prompt .. " " .. Stygian.leftBracket .. Stygian.balances.sub_prompt .. Stygian.pipe .. Stygian.balances.super_prompt .. Stygian.pipe .. Stygian.balances.id_prompt .. Stygian.rightBracket
  elseif Stygian.config.psi == 0 and Stygian.config.armbal == 1 then
    promptstring = Stygian_equilibrium_prompt .. Stygian.balances.leftArm_prompt .. Stygian.balances.rightArm_prompt .. Stygian_balance_prompt .. "<purple>|" .. Stygian.defs.kafe_prompt .. Stygian.blind_prompt .. Stygian.deaf_prompt .. Stygian.prone_prompt
  elseif Stygian.config.psi == 1 and Stygian.config.armbal == 0 then
    promptstring = Stygian_equilibrium_prompt .. Stygian_balance_prompt .. "<purple>|" .. Stygian.defs.kafe_prompt .. Stygian.blind_prompt .. Stygian.deaf_prompt .. Stygian.prone_prompt .. " " .. Stygian.leftBracket .. Stygian.balances.sub_prompt .. Stygian.pipe .. Stygian.balances.super_prompt .. Stygian.pipe .. Stygian.balances.id_prompt .. Stygian.rightBracket
  else
    promptstring = Stygian_equilibrium_prompt .. Stygian_balance_prompt .. "<purple>|" .. Stygian.defs.kafe_prompt .. Stygian.blind_prompt .. Stygian.deaf_prompt .. Stygian.prone_prompt
  end

  Stygian.healthPercent = math.floor(Stygian.curHealth / Stygian.maxHealth * 100)
  if Stygian.healthPercent > 70 then 
    Stygian_health_color = "<green>"
  elseif Stygian.healthPercent < 70 and Stygian.healthPercent > 25 then 
    Stygian_health_color = "<yellow>"
  else 
    Stygian_health_color = "<red>" 
  end

  Stygian.manaPercent = math.floor(Stygian.curMana / Stygian.maxMana * 100)
  if Stygian.manaPercent > 70 then
    Stygian_mana_color = "<light_sky_blue>"
  elseif Stygian.manaPercent < 70 and Stygian.manaPercent > 25 then
    Stygian_mana_color = "<dodger_blue>"
  else
    Stygian_mana_color = "<medium_blue>"
  end

  Stygian.egoPercent = math.floor(Stygian.curEgo / Stygian.maxEgo * 100)
  if Stygian.egoPercent > 70 then 
    Stygian_ego_color = "<peru>"
  elseif Stygian.egoPercent < 70 and Stygian.egoPercent > 25 then 
    Stygian_ego_color = "<chocolate>"
  else 
    Stygian_ego_color = "<saddle_brown>" 
  end
  Stygian.endurancePercent = math.floor(Stygian.curEndurance / Stygian.maxEndurance * 100)
  Stygian.willpowerPercent = math.floor(Stygian.curWillpower / Stygian.maxWillpower * 100)
if Stygian.healthPercent < 100 then Stygian.healthPercent = " " .. Stygian.healthPercent end
if Stygian.manaPercent < 100 then Stygian.manaPercent = " " .. Stygian.manaPercent end
if Stygian.egoPercent < 100 then Stygian.egoPercent = " " .. Stygian.egoPercent end
if Stygian.endurancePercent < 100 then Stygian.endurancePercent = " " .. Stygian.endurancePercent end
if Stygian.willpowerPercent < 100 then Stygian.willpowerPercent = " " .. Stygian.willpowerPercent end
  Stygian.leftBracket = "<forest_green>["
  Stygian.rightBracket = "<forest_green>]"
  Stygian.pipe = "<forest_green>|"
  Stygian_endurance_color = "<orange>"
  Stygian_willpower_color = "<blue_violet>"
--display(Stygian.config.armbal)

  local targap = string.rep(" ", 20 - string.len(target or ""))
  local targap2 = string.rep(" ", 20 - string.len(Stygian.dtarget or ""))
  local echostring = Stygian.leftBracket .. Stygian_health_color .. Stygian.curHealth .. "h" .. Stygian.pipe .. Stygian_health_color .. Stygian.healthPercent .. "%" .. Stygian.rightBracket .. 
                     Stygian.leftBracket .. Stygian_mana_color .. Stygian.curMana .. "M" .. Stygian.pipe .. Stygian_mana_color .. Stygian.manaPercent .. "%" .. Stygian.rightBracket ..  
                     Stygian.leftBracket .. Stygian_ego_color .. Stygian.curEgo .. "E" .. Stygian.pipe .. Stygian_ego_color .. Stygian.egoPercent .. "%" .. Stygian.rightBracket .. 
                     Stygian.leftBracket .. "<light_slate_blue>" .. Stygian.curPower .. "P" .. Stygian.rightBracket .. 
                     Stygian.leftBracket .. Stygian_endurance_color .. Stygian.endurancePercent .. "%EN" .. Stygian.rightBracket .. 
                     Stygian.leftBracket .. Stygian_willpower_color .. Stygian.willpowerPercent .. "%Wi" .. Stygian.rightBracket .. promptstring
 clearWindow("Stygian.prompt")
 cecho("Stygian.prompt", echostring)
 if Stygian.config.monk == 1 then
		resetFormat("Stygian.prompt")
		echo("Stygian.prompt", " ")
		resetFormat("Stygian.prompt")
		setFgColor("Stygian.prompt", 0,170,255) 
		echo("Stygian.prompt", "Kata: ")
		if Stygian.momentum == 1 then
			setFgColor("Stygian.prompt",249,111,158)
			echo("Stygian.prompt", Stygian.momentum_count.."m ")
			resetFormat("Stygian.prompt")
		else
			setFgColor("Stygian.prompt",80,80,80)
			echo("Stygian.prompt", " m ")
			resetFormat("Stygian.prompt")
		end	
		if Stygian.balances.leftLeg == 1 then
			setFgColor("Stygian.prompt", 69,227,69) 
			echo("Stygian.prompt", "*")
		else
			setFgColor("Stygian.prompt",255,83,34)
			echo("Stygian.prompt", "*")
		end
		if Stygian.balances.leftArm == 1 then
			setFgColor("Stygian.prompt", 69,227,69)
			echo("Stygian.prompt", "*")
		else
			setFgColor("Stygian.prompt",255,83,34) 
			echo("Stygian.prompt", "*")
		end
		if Stygian.balances.rightArm == 1 then
			setFgColor("Stygian.prompt", 69,227,69)
			echo("Stygian.prompt", "*")
		else
			setFgColor("Stygian.prompt",255,83,34)
			echo("Stygian.prompt", "*")
		end
	
		if Stygian.balances.rightLeg == 1 then
			setFgColor("Stygian.prompt", 69,227,69)
			echo("Stygian.prompt", "*")
		else
			setFgColor("Stygian.prompt",255,83,34)
			echo("Stygian.prompt", "*")
		end
       echo("Stygian.prompt", "  ")
		resetFormat()	
  end
  echostring =  "     <green:>Targeting: " .. target .. targap .. "Debate target: " .. Stygian.dtarget .. targap2
  cecho("Stygian.prompt", echostring)
end
Stygian_create_prompt()
